package com.welink.cmp.dao.metadata;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.welink.cmp.dao.metadata.dataobject.DataCenterDO;
import com.welink.cmp.dao.metadata.dataobject.RegionDO;
import com.welink.cmp.dto.metadata.datacenter.DatacenterPageQry;
import com.welink.cmp.dto.metadata.region.RegionPageQry;
import org.springframework.stereotype.Component;

/**
 * VPC Dao Service
 * 提供VPC的CRUD操作
 *
 * @author yanwei li
 * @create 2024-05-20 21:23
 */
@Component
public class DataCenterDaoService extends ServiceImpl<DataCenterMapper, DataCenterDO> {
    /**
     * 分页查询机房信息
     *
     * @param pageQry 分页查询条件，包括分页信息和查询条件
     * @return 分页结果，包括机房列表和分页信息
     */
    public Page<DataCenterDO> pageQry(DatacenterPageQry pageQry) {
        Page<DataCenterDO> page = new Page<>(pageQry.getPageIndex(), pageQry.getPageSize());
        LambdaQueryWrapper<DataCenterDO> wrapper = new LambdaQueryWrapper<>();
        if (pageQry.getCode() != null) {
            wrapper.eq(DataCenterDO::getCode, pageQry.getCode());
        }
        if (pageQry.getStrCreateTime() != null) {
            wrapper.ge(DataCenterDO::getCreateTime, pageQry.getStrCreateTime());
        }
        if (pageQry.getEndCreateTime() != null) {
            wrapper.le(DataCenterDO::getCreateTime, pageQry.getEndCreateTime());
        }
        return this.page(page, wrapper);
    }
}

